home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / SASETUP.MSI / F77530_contexthelp.asp < prev    next >
Encoding:
Text File  |  2003-02-21  |  3.0 KB  |  109 lines

  1. <%    '==================================================
  2.     ' Microsoft Server Appliance
  3.     '
  4.     ' Context Help driver routines
  5.     '
  6.     ' Copyright (c) Microsoft Corporation.  All rights reserved.
  7.     '================================================== %>
  8.  
  9. <% Option explicit %>
  10. <!-- #include file="sh_page.asp"         -->
  11. <!-- Copyright (c) Microsoft Corporation.  All rights reserved.-->
  12. <%
  13.     Dim G_strRequestContext
  14.     Dim G_strHelpURL
  15.  
  16.     G_strRequestContext = StripContextParams(Request.QueryString("URL"))
  17.  
  18.     If FindContextHelpURL(G_strRequestContext, G_strHelpURL) Then
  19.         Call SA_TraceOut("CONTEXTHELP", "Context: " + G_strRequestContext + "  Help URL: " + G_strHelpURL)
  20.         Response.Redirect(G_strHelpURL)
  21.     Else
  22.         Dim sRootDir
  23.         Call SA_GetHelpRootDirectory(sRootDir)
  24.         
  25.         Call SA_TraceOut("CONTEXTHELP", "Unable to locate Context: " + G_strRequestContext + "  Defaulting to Help URL: " + sRootDir+"_sak_no_topic_available.htm")
  26.         Response.Redirect(sRootDir+"_sak_no_topic_available.htm")
  27.     End If
  28.     
  29.     
  30. Function FindContextHelpURL(ByVal context, ByRef strContextHelpURL )    
  31.     Dim objElements
  32.     Dim element
  33.     Dim sRootDir
  34.     on error resume next
  35.     Err.Clear
  36.     
  37.     FindContextHelpURL = FALSE
  38.  
  39.     Call SA_GetHelpRootDirectory(sRootDir)
  40.     
  41.     'SA_TraceOut "CONTEXTHELP", "Searching for HELP url on context: " + context
  42.     
  43.     Set objElements = GetElements("CONTEXTHELP")
  44.     for each element in objElements
  45.         Dim strContextURL
  46.         
  47.         strContextURL = element.GetProperty("ContextURL")
  48.         If (Err.Number <> 0) Then
  49.             SA_TraceOut "CONTEXTHELP", "Invalid/missing ContextURL in ElementID "+ element.GetProperty("ElementID")
  50.             Exit For
  51.         End If
  52.  
  53.         If IsSameURL( context, StripContextParams(m_VirtualRoot + strContextURL) )  Or  IsSameSubText(context, StripContextParams(m_VirtualRoot + strContextURL)) Then
  54.             strContextHelpURL = element.GetProperty("URL")
  55.             If (Err.Number <> 0) Then
  56.                 SA_TraceOut "CONTEXTHELP", "Invalid/missing URL in ElementID  "+ element.GetProperty("ElementID")
  57.                 Exit For
  58.             End If
  59.             strContextHelpURL = sRootDir + strContextHelpURL
  60.             Call SA_MungeURL(strContextHelpURL, SAI_FLD_PAGEKEY, SAI_GetPageKey())
  61.             FindContextHelpURL = TRUE
  62.             Exit For
  63.         End If
  64.     Next
  65.  
  66.     Set objElements = nothing
  67. End Function
  68.  
  69.  
  70. Function IsSameURL(ByVal s1, ByVal s2)
  71.     Const vbTextCompare = 1 
  72.     'SA_TraceOut "CONTEXTHELP", "IsSameURL( " + s1 + ", " + s2 + ")"
  73.     
  74.     If ( 0 = StrComp( UCase(s1), UCase(s2), vbTextCompare )) Then
  75.         IsSameURL = TRUE
  76.     Else
  77.         IsSameURL = FALSE
  78.     End If
  79. End Function
  80.  
  81.  
  82. Function IsSameSubText(ByVal s1, ByVal s2)
  83.     Const vbTextCompare = 1 
  84.     'SA_TraceOut "CONTEXTHELP", "IsSameSubText( " + s1 + ", " + s2 + ")"
  85.     
  86.  
  87.     If  Instr( 1, s1, s2,0 ) > 0  Or  Instr( 1, s2, s1,0 ) > 0   Then
  88.         IsSameSubText = TRUE
  89.     Else
  90.         IsSameSubText = FALSE
  91.     End If
  92. End Function
  93.  
  94.  
  95. Function StripContextParams(ByRef s)
  96.     Dim offset
  97.  
  98.     'offset = InStr(s, "?")
  99.     'If ( offset > 0 ) Then
  100.     '    s = Left(s, offset-1)
  101.     'End If
  102.  
  103.     StripContextParams = s
  104. End Function
  105.  
  106.  
  107. %>
  108.  
  109.